
#include <BFont>
#include <BStyle>
#include "member_BStatusBar.h"

using namespace BWE;

member_BStatusBar::member_BStatusBar(BStatusBar* statusBar)
{
	boss = statusBar;
	ia_align = Align_VCenter;
	ia_form = Form_None;
	color.set(255, 255, 255);
	fadeTime = 0;
	dirty = true;
	imageSize.set(-1, -1);
	alpha = 1.0f;
	timeout = -1;
	lastTick = 0;
}
member_BStatusBar::~member_BStatusBar()
{

}

void member_BStatusBar::freshRects()
{
	const BRect& crect = boss->centerRect();
	const BFont* font = boss->realFont();
	const BStyle* style = boss->realStyle();
	if (style)
		style->translate(text, block.text);
	if (block.text.empty())
		block.text = text;

	block.font = font;
	block.reset();
	block.adjust(0);
	ia_textSize = block.size();

	ia_iconSize = imageSize;
	if (image)
	{
		if (ia_iconSize.width() < 0)
			ia_iconSize.width() = image->width();
		if (ia_iconSize.height() < 0)
			ia_iconSize.height() = image->height();
		if (ia_iconSize.width() < 0)
			ia_iconSize.width() = font->size();
		if (ia_iconSize.height() < 0)
			ia_iconSize.height() = font->size();
		ia_iconSize = crect.size().wrap(ia_iconSize);
	}
	adjust(crect);
	block = ia_textRect;
}
